#pragma once
#include "..\Common\Global.h"

template <typename I,typename O>
class Combinator_And : public Combinator<I,O>
{
public:
	Combinator_And(Combinator_Node<I,O>& _left,Combinator_Node<I,O>& _right,Combinator_MemoryManager<I,O>* _MM) : left(_left),right(_right),Combinator<I,O>(_MM){}

	virtual O Parser(I& input)
	{
		O Result(GetMM());
		I temp = input;
		if(O Result1 = left.Parser(input))
		{
			if(O Result2 = right.Parser(input))
			{
				Result = Result1 + Result2;
			}
			else input = temp;
		}
		return Result;
	}
protected:
	Combinator_Node<I,O>& left;
	Combinator_Node<I,O>& right;
};
